let ajaxTimes = 0;
export const request = (parama) => {
  ajaxTimes++;
  wx.showLoading({
    title: "加载中",
    mask: true
  });
  return new Promise((resolve, reject) => {
    //"https://api-hmugo-web.itheima.net/api/public/v1/categories"
    const baseUrl = "https://api-hmugo-web.itheima.net/api/public/v1/";
    wx.request({
      ...parama,
      url: baseUrl + parama.url,
      success: (result) => {
        resolve(result.data.message);
      },
      fail: (err) => {
        reject(err)
      },
      complete: () => {
        ajaxTimes--;
        if (ajaxTimes == 0) {
          wx.hideLoading();
        }
      }
    })
  })
}